home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 2.iso / toolbox / public / figlet / figlet2.1.1 / showfigfonts < prev   
Text File  |  1996-11-11  |  1KB  |  61 lines

  1. #!/bin/sh -
  2. # showfigfonts by Glenn Chappell <ggc@uiuc.edu> (with help from many others)
  3. # 28 Apr 1995
  4. # Based on showfigfonts by Greg Galperin <grg@ai.mit.edu>, Nov 1993.
  5. #
  6. # Prints a list of available figlet fonts, along with a sample of each
  7. # font.  If directory is given, lists fonts in that directory; otherwise
  8. # uses the default font directory.  If word is given, prints that word
  9. # in each font; otherwise prints the font name.
  10. #
  11. # Usage: showfigfonts [ -d directory ] [ word ]
  12.  
  13. # Set up PATH so figlet can be found
  14. DIRSAVE=`pwd`
  15. cd `(dirname "$0") 2>/dev/null`
  16. PATH="$PATH":`pwd`
  17. cd "$DIRSAVE"
  18.  
  19. # Get figlet version
  20. FIGVERSION=`figlet -I1 2>/dev/null`
  21. if [ -z "$FIGVERSION" ]; then
  22.   FIGVERSION=20000
  23. fi
  24.  
  25. USAGE="Usage: `basename $0` [ -d directory ] [ word ]"
  26.  
  27. if [ "$1" = '-d' ]; then
  28.   FONTDIR="$2"
  29.   WORD="$3"
  30.   if [ $# -gt 3 ] || [ $# -lt 2 ]; then
  31.     echo "$USAGE" >&2
  32.     exit 1
  33.   fi
  34. else
  35.   WORD="$1"
  36.   if [ $# -gt 1 ]; then
  37.     echo "$USAGE" >&2
  38.     exit 1
  39.   fi
  40.   if [ "$FIGVERSION" -lt 20100 ]; then
  41.     # figlet 2.0
  42.     FONTDIR="`figlet -F | sed -e '1d' -e '3,$d' -e 's/.*: //'`"
  43.   else
  44.     # figlet 2.1 or later
  45.     FONTDIR="`figlet -I2`"
  46.   fi
  47. fi
  48.  
  49. cd "$FONTDIR"
  50. FONTLIST=`ls *.flf | sed s/\.flf$//`
  51. cd $DIRSAVE
  52. for F in $FONTLIST ; do
  53.   echo "$F" :
  54.   if [ -n "$WORD" ]; then
  55.     echo "$WORD" | figlet -d "$FONTDIR" -f "$F"
  56.   else
  57.     echo "$F" | figlet -d "$FONTDIR" -f "$F"
  58.   fi
  59.   echo "" ; echo ""
  60. done
  61.